import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/l10n.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/entities/setting_data_entity.dart';
import 'package:finance_app/src/utils/cash_utils.dart';
import 'package:finance_app/src/widgets/form/form_edit_status_inherited_widget.dart';
import 'package:flutter/material.dart';

class CurrencyGstAmountFormItem extends StatelessWidget {
  final SettingDataCurrency currency;
  final SettingDataTax tax;
  final String amount;
  final bool showHeader;
  final bool isInclusiveGst;
  final Border border;

  const CurrencyGstAmountFormItem({
    Key key,
    this.showHeader = false,
    this.currency,
    this.tax,
    this.isInclusiveGst,
    this.amount,
    this.border = const Border(
        bottom: BorderSide(
      color: aceGrayColor,
      width: 0.5,
    )),
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(color: Colors.white, border: border),
      padding: EdgeInsets.symmetric(horizontal: getDp(35), vertical: getDp(10)),
      child: Row(
        children: [
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                if (showHeader)
                  Padding(
                    padding: EdgeInsets.only(
                      bottom: getDp(10),
                    ),
                    child: Text(
                      S.current.amount,
                      style: TextStyle(
                        color: aceDarkGrayColor,
                        fontSize: getSp(14),
                        fontWeight: FontWeight.w400,
                        height: 1,
                      ),
                    ),
                  ),
                Text(
                  '${currency.key} ${CashUtils.formatCashAmountString(amount)}',
                  style: FormEditStatusInheritedWidget.ofStyle(context),
                )
              ],
            ),
          ),
          Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              if (showHeader)
                Padding(
                  padding: EdgeInsets.only(
                    bottom: getDp(10),
                  ),
                  child: Text(
                    S.current.gst_rate,
                    style: TextStyle(
                      color: aceDarkGrayColor,
                      fontSize: getSp(14),
                      fontWeight: FontWeight.w400,
                      height: 1,
                    ),
                  ),
                ),
              Text(
                '${tax?.rate}% ${tax?.key}',
                style: FormEditStatusInheritedWidget.ofStyle(context),
              )
            ],
          ),
          SizedBox(
            width: getDp(16),
          ),
          Column(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              if (showHeader)
                Padding(
                  padding: EdgeInsets.only(
                    bottom: getDp(10),
                  ),
                  child: Text(
                    S.current.tax_inclusive,
                    style: TextStyle(
                      color: aceDarkGrayColor,
                      fontSize: getSp(14),
                      fontWeight: FontWeight.w400,
                      height: 1,
                    ),
                  ),
                ),
              Text(
                '${isInclusiveGst ? S.current.yes : S.current.no}',
                style: FormEditStatusInheritedWidget.ofStyle(context),
              )
            ],
          ),
        ],
      ),
    );
  }
}
